﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace PIM_ATE
{
    public class ClsDataRcuConfig
    {
        //测试项目
        public string name { get; set; }
        //天线产品代码	
        public string procode { get; set; }
        //天线型号	
        public string procodeType { get; set; }
        //配置文件名	
        public string fileName { get; set; }
        //控制模块个数	
        public int module_count { get; set; }
        //模块序号	
        public int module_index { get; set; }
        //UID总数
        public int uid_count { get; set; }
        //UID长度
        public int uid_length { get; set; }
        //单元详细参数,各单元不同
        public List<ClsDataRcuConfigUnit> unit { get; set; }

        public DataTable toTable()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("name");
            dt.Columns.Add("procode");
            dt.Columns.Add("procodeType");
            dt.Columns.Add("fileName");
            dt.Columns.Add("module_count");
            dt.Columns.Add("module_index");
            dt.Columns.Add("uid_count");
            dt.Columns.Add("uid_length");

            dt.Columns.Add("unit_count");
            dt.Columns.Add("unit_index");
            dt.Columns.Add("port_count");
            dt.Columns.Add("port_name");
            dt.Columns.Add("moduleSn_length");
            dt.Columns.Add("port_location");
            dt.Columns.Add("speed");

            for (int i = 0; i < unit.Count; i++)
            {
                int n = 0;
                DataRow dr = dt.NewRow();
                dr[n++] = name;
                dr[n++] = procode;
                dr[n++] = procodeType;
                dr[n++] = fileName;
                dr[n++] = module_count;
                dr[n++] = module_index;
                dr[n++] = uid_count;
                dr[n++] = uid_length;

                dr[n++] = unit[i].unit_count;
                dr[n++] = unit[i].unit_index;
                dr[n++] = unit[i].port_count;
                dr[n++] = unit[i].port_name;
                dr[n++] = unit[i].moduleSn_length;
                dr[n++] = unit[i].port_location;
                dr[n++] = unit[i].speed;

                dt.Rows.Add(dr);
            }

            return dt;
        }
    };

    public class ClsDataRcuConfigUnit
    {
        //单元数	
        public int unit_count { get; set; }
        //单元号	
        public int unit_index { get; set; }
        //RF端口号	
        public string port_count { get; set; }
        //port端口名称	
        public string port_name { get; set; }
        //天线序列号(ModuleSn)长度	
        public int moduleSn_length { get; set; }
        //端口字符位置	
        public int port_location { get; set; }
        //出厂转速要求
        public int speed { get; set; }
    };
}
